ARG NODE_VERSION=node:20.9.0-alpine


# 使用Node.js镜像作为构建阶段
FROM $NODE_VERSION AS builder
WORKDIR /app
RUN yarn --registry https://registry.npmmirror.com/  
COPY package.json  ./
RUN yarn install
COPY . .
RUN yarn build

# 使用Next.js官方镜像作为运行阶段
FROM $NODE_VERSION
WORKDIR /app
COPY --from=builder /app/nuxt.config.ts /app/nuxt.config.ts
# COPY --from=builder /app/public /app/public
COPY --from=builder /app/package.json /app/package.json
COPY --from=builder /app/node_modules /app/node_modules
COPY --from=builder /app/.output /app/.output
COPY --from=builder /app/.env* /app/
EXPOSE 3009

CMD ["yarn", "preview"]